package org.testis.webautomationmodule.ui.objects;

import org.testis.logging.AtofLogLevel;
import org.testis.webautomationmodule.ui.UIBehaviorDecorator;


public class WaitForCondition extends UIBehaviorDecorator
{

    private String timeout;
    private String condition;


    public WaitForCondition(String condition,
                            String timeout)
    {
        setCondition(condition);
        setTimeout(timeout);
    }


    @Override
    protected boolean setBehavior()
    {
        try {
            getWebAutomationImpl().waitForCondition(getCondition(),
                                                    getTimeout());
            putLog(" passed waiting for condition (" + getCondition() +
                   ") with timeout " +
                   getTimeout(),AtofLogLevel.DEBUG);
        } catch (Exception ex) {
            putLog(" failed waiting for condition (" + getCondition() +
                   ") with timeout " +
                   getTimeout(),AtofLogLevel.ERROR);
        }

        return true;
    }


    public String getCondition()
    {
        return condition;
    }


    public void setCondition(String val)
    {
        this.condition = val;
    }


    public String getTimeout()
    {
        return timeout;
    }


    public void setTimeout(String val)
    {
        this.timeout = val;
    }
}

